package com.dlc.shop.bean.enums;


/**
 * 页面编号（编号的顺序对数据没有影响）
 */

import com.dlc.shop.common.i18n.I18nMessage;

/**
 * @author Yami
 */
public enum FlowLogPageEnum {
    /**
     * 首页
     */
    HOME(1, "首页", "home", "yami.flow.log.home"),
    /**
     * 轮播图
     */
    CAROUSEL(2, "轮播图", "carousel", "yami.flow.log.carousel"),
    /**
     * 商品详情（普通）
     */
    PROD_INFO(3, "商品详情（普通）", "prodInfo", "yami.flow.log.prodinfo"),
    /**
     * 商品详情（秒杀）
     */
    PROD_INFO_SECKILL(4, "商品详情（秒杀）", "prodInfoSeckill", "yami.flow.log.prodinfo.seckill"),
    /**
     * 商品详情（团购）
     */
    PROD_INFO_GROUP_BUG(5, "商品详情（团购）", "prodInfoGroupBug", "yami.flow.log.prodinfo.groupbuy"),
    /**
     * 分类
     */
    CATEGORY(6, "分类", "category", "yami.flow.log.category"),
    /**
     * 满减
     */
    DISCOUNT(7, "满减", "discount", "yami.flow.log.discount"),
    /**
     * 购物车
     */
    SHOP_CART(8, "购物车", "shopCart", "yami.flow.log.shopCart"),
    /**
     * 订单详情
     */
    PLACE_ORDER(9, "订单详情", "placeOrder", "yami.flow.log.placeOrder"),
    /**
     * 支付页面
     */
    PAY(10, "支付页面", "pay", "yami.flow.log.pay"),
    /**
     * 支付成功
     */
    PAY_SUCCESS(11, "支付成功", "paySuccess", "yami.flow.log.paySuccess"),
    /**
     * 个人中心
     */
    USER_CENTER(12, "个人中心", "userCenter", "yami.flow.log.userCenter"),
    /**
     * 订单列表
     */
    ORDER_LIST(13, "订单列表", "orderList", "yami.flow.log.orderList");

    private final Integer id;
    private final String name;

    private final String nameEn;

    private final String i18nTag;

    public Integer value() {
        return id;
    }

    public static String name(Integer id) {
        FlowLogPageEnum[] enums = values();
        for (FlowLogPageEnum statusEnum : enums) {
            if (statusEnum.value().equals(id)) {
                return I18nMessage.getMessage(statusEnum.i18nTag);
            }
        }
        return null;
    }

    FlowLogPageEnum(Integer id, String name, String nameEn, String i18nTag) {
        this.id = id;
        this.name = name;
        this.nameEn = nameEn;
        this.i18nTag = i18nTag;
    }

    public static FlowLogPageEnum instance(String value) {
        FlowLogPageEnum[] enums = values();
        for (FlowLogPageEnum statusEnum : enums) {
            if (statusEnum.value().equals(value)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static FlowLogPageEnum[] allEnum() {
        FlowLogPageEnum[] enums = values();
        return enums;
    }


    public static Integer getProdType(Integer id) {
        if (id.equals(PROD_INFO_GROUP_BUG.value())){
            return 1;
        }
        if (id.equals(PROD_INFO_SECKILL.value())){
            return 2;
        }
        return 0;
    }

    public static Boolean isProdInfo(Integer id) {
        if (id.equals(PROD_INFO.value()) ||id.equals(PROD_INFO_GROUP_BUG.value()) || id.equals(PROD_INFO_SECKILL.value())){
            return true;
        }
        return false;
    }

    public static Boolean isPayOrPaySuccess(Integer id) {
        if (id.equals(PAY.value()) ||id.equals(PAY_SUCCESS.value())){
            return true;
        }
        return false;
    }
}
